package com.macro.mall.controller;

import com.macro.mall.common.api.CommonResult;

import com.macro.mall.model.UmsMemberReceiveAddress;
import com.macro.mall.service.UmsMemberReceiveAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/member")
public class UmsMemberReceiveAddressController {
    @Autowired
    private UmsMemberReceiveAddressService umsMemberService;

    /**
     * 收货地址
     */
    @GetMapping("/address/list")
    public CommonResult<List<UmsMemberReceiveAddress>> list() {
        List<UmsMemberReceiveAddress> list =  umsMemberService.list();
        return CommonResult.success(list);
    }

    /**
     * 添加和修改
     */
    @PostMapping("/address/add")
    public CommonResult addMember(@RequestBody UmsMemberReceiveAddress umsMemberReceiveAddress) {
        return umsMemberService.addMember(umsMemberReceiveAddress);

    }
    /**
     * 添加和修改
     */
    @PostMapping("/address/update")
    public CommonResult update(@RequestBody UmsMemberReceiveAddress umsMemberReceiveAddress) {
        return umsMemberService.update(umsMemberReceiveAddress);

    }
    /**
     * 删除
     */
    @PostMapping("/address/delete/{id}")
    public int del(@PathVariable Long id) {
        return umsMemberService.del(id);
    }

    /**
     * 回显
     */
    @GetMapping("/address/{id}")
    public CommonResult<UmsMemberReceiveAddress> byid(@PathVariable Long id) {
        UmsMemberReceiveAddress byid = umsMemberService.byid(id);
        return CommonResult.success(byid);
    }
}
